<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="chinese">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
      
    
    
      
    
  <script src="//cdn.jsdelivr.net/npm/pace-js@1/pace.min.js"></script>
  <link href="//cdn.jsdelivr.net/npm/pace-js@1/themes/blue/pace-theme-minimal.min.css" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">










<meta name="description" content="第十三章 字符串字符串操作是程序设计中的最常见的行为。 13.1 不可变的string String对象是不可变的，每一个看似修改了String值的方法，实际都是产生了一个新的字符串。 123456789101112public class Immutable &amp;#123;	public static String upCase(String s)&amp;#123;		return s.toUpperC">
<meta name="keywords" content="Java Php hexo Thinking in Java">
<meta property="og:type" content="article">
<meta property="og:title" content="Thinking in Java 第十三章">
<meta property="og:url" content="http://yoursite.com/2019/08/10/Thinking-in-Java-第十三章/index.html">
<meta property="og:site_name" content="坚持就是胜利">
<meta property="og:description" content="第十三章 字符串字符串操作是程序设计中的最常见的行为。 13.1 不可变的string String对象是不可变的，每一个看似修改了String值的方法，实际都是产生了一个新的字符串。 123456789101112public class Immutable &amp;#123;	public static String upCase(String s)&amp;#123;		return s.toUpperC">
<meta property="og:locale" content="chinese">
<meta property="og:updated_time" content="2019-08-10T15:30:47.289Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Thinking in Java 第十三章">
<meta name="twitter:description" content="第十三章 字符串字符串操作是程序设计中的最常见的行为。 13.1 不可变的string String对象是不可变的，每一个看似修改了String值的方法，实际都是产生了一个新的字符串。 123456789101112public class Immutable &amp;#123;	public static String upCase(String s)&amp;#123;		return s.toUpperC">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":14,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '190coder'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2019/08/10/Thinking-in-Java-第十三章/">





  <title>Thinking in Java 第十三章 | 坚持就是胜利</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="chinese">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">坚持就是胜利</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/10/Thinking-in-Java-第十三章/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="190coder">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="坚持就是胜利">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Thinking in Java 第十三章</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2019-08-10T23:28:36+08:00">
                2019-08-10
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index">
                    <span itemprop="name">Java</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="第十三章-字符串"><a href="#第十三章-字符串" class="headerlink" title="第十三章 字符串"></a>第十三章 字符串</h1><p>字符串操作是程序设计中的最常见的行为。</p>
<h2 id="13-1-不可变的string"><a href="#13-1-不可变的string" class="headerlink" title="13.1 不可变的string"></a>13.1 不可变的string</h2><p> String对象是不可变的，每一个看似修改了String值的方法，实际都是产生了一个新的字符串。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">public class Immutable &#123;</span><br><span class="line">	public static String upCase(String s)&#123;</span><br><span class="line">		return s.toUpperCase();</span><br><span class="line">	&#125;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		String q = &quot;howdy&quot;;</span><br><span class="line">		System.out.println(q);</span><br><span class="line">		String qq = upCase(q);</span><br><span class="line">		System.out.println(qq);</span><br><span class="line">		System.out.println(q);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>当把q传给upCase方法时，实际上传递的是引用的一个拷贝。</p>
<p>方法的参数是用来传递信息的，而不是用来改变原有对象本身的。</p>
<h2 id="13-2-重载“-”与StringBuilder"><a href="#13-2-重载“-”与StringBuilder" class="headerlink" title="13.2 重载“+”与StringBuilder"></a>13.2 重载“+”与StringBuilder</h2><p>String对象是不可变的，所以指向它的任何引用都不会改变该对象的值。不可变性会对效率带来一个问题，为String对象重载“+”操作符就是一个例子，重载的意思是一个操作符应用与特定的类时被赋有特殊的意义。（用于String的“+”和”+=”是Java中仅有的两个重载过的操作符，Java不允许程序员自己重载操作符）<br>操作符“+”可以用来连接两个String</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">public class Concatetion &#123;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		String mango = &quot;mango&quot;;</span><br><span class="line">		String s = &quot;abc&quot; + mango + &quot;def&quot; + 42;</span><br><span class="line">		System.out.println(s);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;上述代码的运行过程可能是这样的：<strong>String可能有一个append方法，然后它会生成一个新的String对象用来连接abc和mango，然后该对象再与def相连生成新的对象，依次类推</strong>。这样做的话会产生很多中间垃圾需要清理因此它效率极低。<br>可以使用JDK自带的反编译工具查看上述代码如何工作。</p>
<p>&emsp;&emsp;在编写一个类似toString（）的方法时，如果字符串较短时，我们可以使用普通的拼接方式，当字符串操作较为复杂的时候，我们在代码中直接创建一个StringBuilder对象进行操作效率会更加优异。</p>
<h2 id="13-3-无意识的递归"><a href="#13-3-无意识的递归" class="headerlink" title="13.3 无意识的递归"></a>13.3 无意识的递归</h2><p>使用toString（）方法打印出对象的内存地址，那么我们可能会考虑使用this关键字：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">import java.util.ArrayList;</span><br><span class="line">import java.util.List;</span><br><span class="line">public class InfiniteRecursion &#123;</span><br><span class="line">	public String toString()&#123;</span><br><span class="line">		return &quot;InfiniteRecursion address&quot; + this;</span><br><span class="line">	&#125;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		List&lt;InfiniteRecursion&gt; v = new ArrayList&lt;InfiniteRecursion&gt;();</span><br><span class="line">		for(int i = 0;i&lt;10;i++)&#123;</span><br><span class="line">			v.add(new InfiniteRecursion());</span><br><span class="line">		&#125;</span><br><span class="line">		System.out.println(v);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>这里当运行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">return &quot;InfiniteRecursion address&quot; + this;</span><br></pre></td></tr></table></figure>

<p>时发生了类型转换，编译器发现“+”后边不是String类型，会试图转换成String类型，转换的方式就是调用toString方法，因此会递归调用，此处如果想正确打印地址，那么需要使用其基类Object的toString（）方法。</p>
<h2 id="13-4-String上的操作"><a href="#13-4-String上的操作" class="headerlink" title="13.4 String上的操作"></a>13.4 String上的操作</h2><p>所有的类都是Class类的对象，使用Class类的getMethods（）方法可以返回该类的所有方法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">import java.lang.reflect.Method;</span><br><span class="line">public class StringMethods &#123;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		Class&lt;String&gt; c = String.class;</span><br><span class="line">		Method[] methods = c.getMethods();</span><br><span class="line">		for(Method method :methods)&#123;</span><br><span class="line">			System.out.println(method);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br></pre></td><td class="code"><pre><span class="line">public int java.lang.String.hashCode()</span><br><span class="line">//比较两个字符串 重载了Object的方法 当两个字符串值相同、类型相同则认为相同 忽略了引用</span><br><span class="line">public boolean java.lang.String.equals(java.lang.Object)</span><br><span class="line">public java.lang.String java.lang.String.toString()</span><br><span class="line">//获取指定索引下标位置上的字符</span><br><span class="line">public char java.lang.String.charAt(int)</span><br><span class="line">public int java.lang.String.codePointAt(int)</span><br><span class="line">public int java.lang.String.codePointBefore(int)</span><br><span class="line">public int java.lang.String.codePointCount(int,int)</span><br><span class="line">public int java.lang.String.compareTo(java.lang.Object)</span><br><span class="line">//按词典顺序比较两个字符串 大小写并不等价</span><br><span class="line">public int java.lang.String.compareTo(java.lang.String)</span><br><span class="line">public int java.lang.String.compareToIgnoreCase(java.lang.String)</span><br><span class="line">//字符串连接 返回一个新的String为指定String连接参数</span><br><span class="line">public java.lang.String java.lang.String.concat(java.lang.String)</span><br><span class="line">//查找字符串中是否包含指定字符 存在返回true</span><br><span class="line">public boolean java.lang.String.contains(java.lang.CharSequence)</span><br><span class="line">//比较两个字符串</span><br><span class="line">public boolean java.lang.String.contentEquals(java.lang.StringBuffer)</span><br><span class="line">public boolean java.lang.String.contentEquals(java.lang.CharSequence)</span><br><span class="line">public static java.lang.String java.lang.String.copyValueOf(char[])</span><br><span class="line">public static java.lang.String java.lang.String.copyValueOf(char[],int,int)</span><br><span class="line">public boolean java.lang.String.endsWith(java.lang.String)</span><br><span class="line">//比较字符串是否相同 忽略大小写</span><br><span class="line">public boolean java.lang.String.equalsIgnoreCase(java.lang.String)</span><br><span class="line">public static java.lang.String java.lang.String.format(java.lang.String,java.lang.Object[])</span><br><span class="line">public static java.lang.String java.lang.String.format(java.util.Locale,java.lang.String,java.lang.Object[])</span><br><span class="line">public void java.lang.String.getBytes(int,int,byte[],int)</span><br><span class="line">public byte[] java.lang.String.getBytes(java.lang.String) throws java.io.UnsupportedEncodingException</span><br><span class="line">public byte[] java.lang.String.getBytes(java.nio.charset.Charset)</span><br><span class="line">public byte[] java.lang.String.getBytes()</span><br><span class="line">// s.getChars(1,2,char,3) 赋值s串中下标为1-2的到char中 char中起始位置为3</span><br><span class="line">public void java.lang.String.getChars(int,int,char[],int)</span><br><span class="line">public int java.lang.String.indexOf(int,int)</span><br><span class="line">public int java.lang.String.indexOf(java.lang.String,int)</span><br><span class="line">//是否包含该字符 包含返回下标 否则返回-1</span><br><span class="line">public int java.lang.String.indexOf(java.lang.String)</span><br><span class="line">public int java.lang.String.indexOf(int)</span><br><span class="line">public native java.lang.String java.lang.String.intern()</span><br><span class="line">public boolean java.lang.String.isEmpty()</span><br><span class="line">public int java.lang.String.lastIndexOf(int,int)</span><br><span class="line">public int java.lang.String.lastIndexOf(java.lang.String)</span><br><span class="line">public int java.lang.String.lastIndexOf(java.lang.String,int)</span><br><span class="line">public int java.lang.String.lastIndexOf(int)</span><br><span class="line">//String 中字符的个数</span><br><span class="line">public int java.lang.String.length()</span><br><span class="line">public boolean java.lang.String.matches(java.lang.String)</span><br><span class="line">public int java.lang.String.offsetByCodePoints(int,int)</span><br><span class="line">public boolean java.lang.String.regionMatches(boolean,int,java.lang.String,int,int)</span><br><span class="line">public boolean java.lang.String.regionMatches(int,java.lang.String,int,int)</span><br><span class="line">//把字符串中的第一个参数字符替换成第二个</span><br><span class="line">public java.lang.String java.lang.String.replace(char,char)</span><br><span class="line">public java.lang.String java.lang.String.replace(java.lang.CharSequence,java.lang.CharSequence)</span><br><span class="line">public java.lang.String java.lang.String.replaceAll(java.lang.String,java.lang.String)</span><br><span class="line">public java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)</span><br><span class="line">public java.lang.String[] java.lang.String.split(java.lang.String,int)</span><br><span class="line">public java.lang.String[] java.lang.String.split(java.lang.String)</span><br><span class="line">public boolean java.lang.String.startsWith(java.lang.String,int)</span><br><span class="line">//字符串起始串</span><br><span class="line">public boolean java.lang.String.startsWith(java.lang.String)</span><br><span class="line">public java.lang.CharSequence java.lang.String.subSequence(int,int)</span><br><span class="line">//字符串截断</span><br><span class="line">public java.lang.String java.lang.String.substring(int)</span><br><span class="line">public java.lang.String java.lang.String.substring(int,int)</span><br><span class="line">//返回一个字符数组，该字符数组包含字符串的所有字符</span><br><span class="line">public char[] java.lang.String.toCharArray()</span><br><span class="line">//字符串字符转换成小写</span><br><span class="line">public java.lang.String java.lang.String.toLowerCase()</span><br><span class="line">public java.lang.String java.lang.String.toLowerCase(java.util.Locale)</span><br><span class="line">//字符串字符转换成大写</span><br><span class="line">public java.lang.String java.lang.String.toUpperCase()</span><br><span class="line">public java.lang.String java.lang.String.toUpperCase(java.util.Locale)</span><br><span class="line">//删除String两端的空白字符</span><br><span class="line">public java.lang.String java.lang.String.trim()</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(char)</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(float)</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(int)</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(long)</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(double)</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(java.lang.Object)</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(char[])</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(char[],int,int)</span><br><span class="line">public static java.lang.String java.lang.String.valueOf(boolean)</span><br><span class="line">public final native java.lang.Class java.lang.Object.getClass()</span><br><span class="line">public final native void java.lang.Object.notify()</span><br><span class="line">public final native void java.lang.Object.notifyAll()</span><br><span class="line">public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException</span><br><span class="line">public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException</span><br><span class="line">public final void java.lang.Object.wait() throws java.lang.InterruptedException</span><br></pre></td></tr></table></figure>

<h2 id="13-5-格式化输出"><a href="#13-5-格式化输出" class="headerlink" title="13.5 格式化输出"></a>13.5 格式化输出</h2><p>JavaSE5提供了格式化输出功能，这一功能使得控制输出的功能变得更加简单，同时也给开发者带来了更加强大的代码输出控制能力。JavaSE5引入的format方法可以用于PrintStream或PrintWriter对象，其中也包括System.out对象。format（）方法模仿在C语言的printf（）如下简单示例</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">public class SimpleFormat &#123;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		int x = 5;</span><br><span class="line">		double y = 5.333221;</span><br><span class="line">		System.out.println(&quot;Row1: [&quot; + x + &quot; &quot; + y + &quot;]&quot;);</span><br><span class="line">		System.out.format(&quot;Row1: [%d %f]\n&quot;,x,y);</span><br><span class="line">		System.out.printf(&quot;Row1: [%d %f]\n&quot;,x,y);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>format（）与printf（）相同，只需要加上对应的格式化字符即可。<br>Java中所有新的格式化功能都由java.util.Formatter类处理，可以将其看做是一个翻译器，它将你的格式化字符串和数据翻译成想要的结果。当你创建了一个Formatter对象的时候，需要向编译器传递一些信息，告诉他最终的结果将向哪里输出。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">import java.io.PrintStream;</span><br><span class="line">import java.util.Formatter;</span><br><span class="line">public class Tutle &#123;</span><br><span class="line">	private String name;</span><br><span class="line">	private Formatter f;</span><br><span class="line">	public Tutle(String name,Formatter f)&#123;</span><br><span class="line">		this.f = f;</span><br><span class="line">		this.name = name;</span><br><span class="line">	&#125;</span><br><span class="line">	public void move(int x,int y)&#123;</span><br><span class="line">		f.format(&quot;%s The Tutle is at (%d,%d)\n&quot;,name,x,y);</span><br><span class="line">	&#125;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		Tutle tommy = new Tutle(&quot;Tommy&quot;,new Formatter(System.out));</span><br><span class="line">		Tutle terry = new Tutle(&quot;Terry&quot;,new Formatter(System.err));</span><br><span class="line">		tommy.move(0, 4);</span><br><span class="line">		terry.move(4, 8);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p> 有的时候我们希望做一些更精致的格式化信息，比如控制空格与对齐，最常见的是控制域的最小尺寸，这可以通过指定width实现，Formatter对象通过在必要时添加空格，来确保一个域至少达到某个长度。默认情况下域是右对齐的，不过也可以通过“-”指定数据的对齐方式。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">import java.util.Formatter;</span><br><span class="line">public class Reciept &#123;</span><br><span class="line">	private double total = 0;</span><br><span class="line">	private Formatter f = new Formatter(System.out);</span><br><span class="line">	public void printTitle()&#123;</span><br><span class="line">		f.format(&quot;%-15s %5s %10s\n&quot;,&quot;Item&quot;,&quot;Qty&quot;,&quot;Price&quot;);</span><br><span class="line">		f.format(&quot;%-15s %5s %10s\n&quot;,&quot;----&quot;,&quot;---&quot;,&quot;-----&quot;);</span><br><span class="line">	&#125;</span><br><span class="line">	public void print(String name,int qty,double price)&#123;</span><br><span class="line">		f.format(&quot;%-15.15s %5d %10.2f\n&quot;,name,qty,price);</span><br><span class="line">		total+=price;</span><br><span class="line">	&#125;</span><br><span class="line">	public void printTotal()&#123;</span><br><span class="line">		f.format(&quot;%-15.15s %5s %10.2f\n&quot;,&quot;Tax&quot;,&quot;&quot;,total*0.06);</span><br><span class="line">		f.format(&quot;%-15.15s %5s %10s\n&quot;,&quot;&quot;,&quot;&quot;,&quot;------&quot;);</span><br><span class="line">		f.format(&quot;%-15.15s %5s %10.2f\n&quot;,&quot;Total&quot;,&quot;&quot;,total*1.06);</span><br><span class="line">	&#125;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		Reciept receipt = new Reciept();</span><br><span class="line">		receipt.printTitle();</span><br><span class="line">		receipt.print(&quot;Jack&apos;s Magic Beans&quot;,4,4.25);</span><br><span class="line">		receipt.print(&quot;Princess Beans&quot;,3,5.1);</span><br><span class="line">		receipt.print(&quot;Thres Bears Porridge&quot;,1,14.25);</span><br><span class="line">		receipt.printTotal();</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>Formatter类也有很多类型转换，常用的类型转换如下</p>
<p>d：整数型（十进制）e：浮点数（科学计数）c：Unicode字符 x：整数（十六进制）b：Boolean值 h：散列码（十六进制）s：String %：字符“%”f：浮点数（十进制），针对不同的数据类型，有些转换是无效的，如果强制使用则会发生异常。</p>
<h2 id="13-6-正则表达式"><a href="#13-6-正则表达式" class="headerlink" title="13.6 正则表达式"></a>13.6 正则表达式</h2><p>&emsp;&emsp;正则表达式就是以某种方式来描述字符串，因此你可以说“如果一个字符串含有某些东西，那么它就是我需要的东西”。\d表示一位数字，Java中对于\反斜线有不同的处理，在其它语言中，\表示我想插入一个普通的反斜线，而在Java中\表示我将要插入一个正则表达式反斜线，所以它后边的值应该具有特殊意义。例如你想表示一个数字，那么就是\d，如果想插入一个普通的反斜线，则需要使用\，不过制表之类的应该使用单反斜线，\d\n，使用？表示可能存在，使用+表示一个或多个+之前的表达式。比如我们要判断可能有一个负号后边跟着一个或多个数字则使用：-？\d+</p>
<p>&emsp;&emsp;应用正则的最简单方式是使用String类提供的方法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">public class IntegerMatch &#123;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		System.out.println(&quot;-1234&quot;.matches(&quot;-?\\d+&quot;));</span><br><span class="line">		System.out.println(&quot;5678&quot;.matches(&quot;-?\\d+&quot;));</span><br><span class="line">		System.out.println(&quot;+911&quot;.matches(&quot;-?\\d+&quot;));</span><br><span class="line">		System.out.println(&quot;+911&quot;.matches(&quot;(-|\\+)?\\d+&quot;));</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p> &emsp;&emsp;String类还带有一个非常有用的正则表达式方法split（），功能是将字符串在正则表达式匹配的地方分割开：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">import java.util.Arrays;</span><br><span class="line"> public class Splitting &#123; </span><br><span class="line">    public static String knights = &quot;Then。when you have found the shrubbery.you must&quot; + &quot;cut down the mightiest tree in the forest。。。&quot; + &quot;with... a herring&quot;; </span><br><span class="line"></span><br><span class="line">    public static void split(String regex)&#123; System.out.println(Arrays.toString(knights.split(regex))); &#125;</span><br><span class="line"></span><br><span class="line">    public static void main(String[] args) &#123; </span><br><span class="line">          split(&quot; &quot;); </span><br><span class="line">          split(&quot;\\W+&quot;);</span><br><span class="line">          split(&quot;\\w+&quot;);</span><br><span class="line">          split(&quot;n\\W+&quot;); </span><br><span class="line">          &#125; </span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;第一个是使用空格拆分，\W表示非单词字符，\w表示单词字符，第三个表示字母n以及后边的一个或多个非单词字符。可见与正则表达式相同的内容都消失了。</p>
<p>&emsp;&emsp;String类自带的最后一个正则表达式方法为替换，你可以替换正则表达式第一个匹配的子串，也可以替换所有匹配的地方。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">public class Replacing &#123;  </span><br><span class="line">    static String s = Splitting.knights;  </span><br><span class="line">    public static void main(String[] args) &#123;  </span><br><span class="line">        System.out.println(s.replaceFirst(&quot;f\\w+&quot;,&quot;located&quot;));  </span><br><span class="line">        System.out.println(s.replaceAll(&quot;shrubbery|tree|herring&quot;,&quot;banana&quot;));  </span><br><span class="line">    &#125;  </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;我们的任务是在能够完成任务的情况下编写简单的易于理解的正则表达式，而不是编写难以理解的正则表达式。<br>我们在使用正则表达式的时候很容易混淆，因为他是一种在Java之上的新语言，CharSequence，该接口从CharBuffer、String、StringBuffer、StringBuilder类之中抽象出了字符序列的一般化定义。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">public interface CharSequence &#123;</span><br><span class="line">	char charAt(int i );</span><br><span class="line">	int length();</span><br><span class="line">	String subSequence(int start,int end);</span><br><span class="line">	String toString();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="13-7-扫描输入"><a href="#13-7-扫描输入" class="headerlink" title="13.7 扫描输入"></a>13.7 扫描输入</h2><p>&emsp;&emsp;读取文本或者从标准输入读取数据一般的解决方法是读入一行文本，然后对其进行分词，然后使用Integer、Double的各种解析方法来解析数据。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">import java.io.BufferedReader;</span><br><span class="line">import java.io.IOException;</span><br><span class="line">import java.io.StringReader;</span><br><span class="line"> </span><br><span class="line">public class SimpleRead &#123;</span><br><span class="line">	public static BufferedReader input = new BufferedReader(new StringReader(&quot;Sir Robin of Camelot\n22 1.523222&quot;));</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		try&#123;</span><br><span class="line">			System.out.println(&quot;What&apos;s your name?&quot;);</span><br><span class="line">			String name = input.readLine();</span><br><span class="line">			System.out.println(name);</span><br><span class="line">			System.out.println(&quot;How old are you?What&apos;s your favorite double&quot;);</span><br><span class="line">			String numbers = input.readLine();</span><br><span class="line">			System.out.println(numbers);</span><br><span class="line">			String numArray[] = numbers.split(&quot; &quot;);</span><br><span class="line">			int age = Integer.parseInt(numArray[0]);</span><br><span class="line">			double favorite = Double.parseDouble(numArray[1]);</span><br><span class="line">			System.out.format(&quot;Hi %s.\n&quot;,name);</span><br><span class="line">			System.out.format(&quot;In 5 years you will be %d. \n&quot;,age+5);</span><br><span class="line">			System.out.format(&quot;My Favorite double is %f.&quot;,favorite/2);</span><br><span class="line">			&#125;catch(IOException e)&#123;</span><br><span class="line">				System.err.println(&quot;I/O Exception&quot;);</span><br><span class="line">			&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;以上代码中，使用了IO中的readLine（）方法读取输入流中的一行，然后进行解析。终于在JavaSE5新增了Scanner类，它可以大大的减轻扫描输入的工作。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">import java.util.Scanner;</span><br><span class="line">public class BetterRead &#123;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		Scanner stdin = new Scanner(SimpleRead.input);</span><br><span class="line">		System.out.println(&quot;What&apos;s your name?&quot;);</span><br><span class="line">		String name = stdin.nextLine();</span><br><span class="line">		System.out.println(name);</span><br><span class="line">		System.out.println(&quot;How old are you?What&apos;s your favorite double&quot;);</span><br><span class="line">		System.out.println(&quot;(input:&lt;age&gt;&lt;double&gt;)&quot;);</span><br><span class="line">		int age = stdin.nextInt();</span><br><span class="line">		double favorite = stdin.nextDouble();</span><br><span class="line">		System.out.println(age);</span><br><span class="line">		System.out.println(favorite);</span><br><span class="line">		System.out.format(&quot;Hi %s.\n&quot;,name);</span><br><span class="line">		System.out.format(&quot;In 5 years you will be %d. \n&quot;,age+5);</span><br><span class="line">		System.out.format(&quot;My Favorite double is %f.&quot;,favorite/2);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;Scanner的构造器可以接受任意类型的输入对象，其普通的next方法将返回一个String，而所有的基本类型都有一个next方法，该方法的作用是，读取到下一个完整的指定类型的分词之后才返回。同时Scanner还有对应的hasNext方法，用来判断是否有所输入分词的类型。<br>Scanner默认的定界符为空白符，我们也可以自己使用正则表达式指定分隔符：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">import java.util.Scanner;</span><br><span class="line">public class ScannerDelimiter &#123;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		Scanner scanner = new Scanner(&quot;12,24    ,35,67&quot;);</span><br><span class="line">		scanner.useDelimiter(&quot;\\s*,\\s*&quot;);</span><br><span class="line">		while(scanner.hasNextInt())&#123;</span><br><span class="line">			System.out.println(scanner.nextInt());</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;这个例子使用逗号以及任意的空白字符来实现字符串的分割。使用useDelimiter（）方法设置定界符，也可以使用delimiter（）方法返回现在所使用的定界符。</p>
<p>&emsp;&emsp;Scanner除了可以扫描基本类型外，还可以扫描正则表达式，这在扫描复杂数据类型的时候非常有用：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">import java.util.Scanner;</span><br><span class="line">import java.util.regex.MatchResult;</span><br><span class="line"> </span><br><span class="line">public class ThreadAnalyzer &#123;</span><br><span class="line">	static String threatData = &quot;58.27.82.161@02/10/2005\n&quot; +</span><br><span class="line">								&quot;204.45.234.40@02/11/2005\n&quot; +</span><br><span class="line">								&quot;58.27.82.161@02/11/2005\n&quot; +</span><br><span class="line">								&quot;58.27.82.161@02/11/2005\n&quot; +</span><br><span class="line">								&quot;58.27.82.161@02/11/2005\n&quot; +</span><br><span class="line">								&quot;[Next log section width different data format]&quot;;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		Scanner scanner = new Scanner(threatData);</span><br><span class="line">		String pattern = &quot;(\\d+[.]\\d+[.]\\d+[.]\\d+)@&quot; + &quot;(\\d&#123;2&#125;/\\d&#123;2&#125;/\\d&#123;4&#125;)&quot;;</span><br><span class="line">		while(scanner.hasNext(pattern))&#123;</span><br><span class="line">			scanner.next(pattern);</span><br><span class="line">			MatchResult match = scanner.match();</span><br><span class="line">			String ip = match.group(1);</span><br><span class="line">			String date = match.group(2);</span><br><span class="line">			System.out.format(&quot;Thread on %s from %s\n&quot;,date,ip);</span><br><span class="line">			</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;当next（）方法配合指定正则表达式使用时，将找到下一个匹配该模式的输入部分，调用match（）方法获得匹配的结果。有一点需要注意，它只针对下一个输入分词进行匹配，如果正则表达式含有定界符，那将永远不能成功。</p>
<h1 id="13-8-StringTokenizer"><a href="#13-8-StringTokenizer" class="headerlink" title="13.8 StringTokenizer"></a>13.8 StringTokenizer</h1><p>&emsp;&emsp;在正则表达式和Scanner引入之前，我们使用的是StringTokenizer来进行字符串匹配，下面演示这种方式并与其它方式进行比较：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">import java.util.Arrays;</span><br><span class="line">import java.util.Scanner;</span><br><span class="line">import java.util.StringTokenizer;</span><br><span class="line"> </span><br><span class="line">public class ReplacingStringTokenizer &#123;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		String input = &quot;But I&apos;m not dead yet!I feel happy!&quot;;</span><br><span class="line">		StringTokenizer stoke = new StringTokenizer(input);</span><br><span class="line">		while(stoke.hasMoreElements())&#123;</span><br><span class="line">			System.out.print(stoke.nextToken() + &quot; &quot;);</span><br><span class="line">		&#125;</span><br><span class="line">		System.out.println();</span><br><span class="line">			System.out.println(Arrays.toString(input.split(&quot; &quot;)));</span><br><span class="line">			Scanner scanner = new Scanner(input);</span><br><span class="line">			while(scanner.hasNext())&#123;</span><br><span class="line">				System.out.print(scanner.next() + &quot; &quot;);</span><br><span class="line">			&#125;</span><br><span class="line">	</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;使用正则表达式或者Scanner我们可以使用更加复杂的模式匹配字符串，而使用StringTokenizer则很困难了，因此实际上StringTokenizer这个类基本上已经被废弃了。</p>
<h2 id="13-9-总结"><a href="#13-9-总结" class="headerlink" title="13.9 总结"></a>13.9 总结</h2><ol>
<li>String类型作为程序设计中最为常见的一种操作类型，它是一种不可变的操作类型。</li>
<li>它内部重载了“+”操作符，使得可以使用”+”操作符完成字符串的拼接工作，拼接的原理是编译器为我们自动生成了StringBuilder类来完成。因此对于复杂的字符串拼接操作，我们自己使用StringBuilder效率会更高一些。</li>
<li>String还有很多常用的方法，正则表达式为我们提供了字符串匹配的多种形式。</li>
</ol>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/08/07/kafka-个人理解以及常用应用场景-kafka-zookeeper-无坑搭建/" rel="next" title="kafka 个人理解以及常用应用场景 & kafka zookeeper 无坑搭建">
                <i class="fa fa-chevron-left"></i> kafka 个人理解以及常用应用场景 & kafka zookeeper 无坑搭建
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/08/10/Thinking-in-Java-第十四章/" rel="prev" title="Thinking in Java 第十四章">
                Thinking in Java 第十四章 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.jpg" alt="190coder">
            
              <p class="site-author-name" itemprop="name">190coder</p>
              <p class="site-description motion-element" itemprop="description">坚信持续学习就一定能超过大多数人</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">53</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">13</span>
                  <span class="site-state-item-name">categories</span>
                </a>
              </div>
            

            

          </nav>

          

          

          
          

          
          

          <div style>
  <canvas id="canvas" style="width:60%;">当前浏览器不支持canvas，请更换浏览器后再试</canvas>
</div>
<script>
(function(){

   var digit=
    [
        [
            [0,0,1,1,1,0,0],
            [0,1,1,0,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,0,1,1,0],
            [0,0,1,1,1,0,0]
        ],//0
        [
            [0,0,0,1,1,0,0],
            [0,1,1,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [1,1,1,1,1,1,1]
        ],//1
        [
            [0,1,1,1,1,1,0],
            [1,1,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,0,0],
            [0,0,1,1,0,0,0],
            [0,1,1,0,0,0,0],
            [1,1,0,0,0,0,0],
            [1,1,0,0,0,1,1],
            [1,1,1,1,1,1,1]
        ],//2
        [
            [1,1,1,1,1,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,0,0,1,1,0],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0]
        ],//3
        [
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,1,0],
            [0,0,1,1,1,1,0],
            [0,1,1,0,1,1,0],
            [1,1,0,0,1,1,0],
            [1,1,1,1,1,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,0,1,1,0],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,1,1]
        ],//4
        [
            [1,1,1,1,1,1,1],
            [1,1,0,0,0,0,0],
            [1,1,0,0,0,0,0],
            [1,1,1,1,1,1,0],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0]
        ],//5
        [
            [0,0,0,0,1,1,0],
            [0,0,1,1,0,0,0],
            [0,1,1,0,0,0,0],
            [1,1,0,0,0,0,0],
            [1,1,0,1,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0]
        ],//6
        [
            [1,1,1,1,1,1,1],
            [1,1,0,0,0,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,1,1,0,0,0],
            [0,0,1,1,0,0,0],
            [0,0,1,1,0,0,0],
            [0,0,1,1,0,0,0]
        ],//7
        [
            [0,1,1,1,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0]
        ],//8
        [
            [0,1,1,1,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,0,0],
            [0,1,1,0,0,0,0]
        ],//9
        [
            [0,0,0,0,0,0,0],
            [0,0,1,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,0,0,0,0,0],
            [0,0,0,0,0,0,0],
            [0,0,1,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,0,0,0,0,0]
        ]//:
    ];

var canvas = document.getElementById('canvas');

if(canvas.getContext){
    var cxt = canvas.getContext('2d');
    //声明canvas的宽高
    var H = 100,W = 700;
    canvas.height = H;
    canvas.width = W;
    cxt.fillStyle = '#f00';
    cxt.fillRect(10,10,50,50);

    //存储时间数据
    var data = [];
    //存储运动的小球
    var balls = [];
    //设置粒子半径
    var R = canvas.height/20-1;
    (function(){
        var temp = /(\d)(\d):(\d)(\d):(\d)(\d)/.exec(new Date());
        //存储时间数字，由十位小时、个位小时、冒号、十位分钟、个位分钟、冒号、十位秒钟、个位秒钟这7个数字组成
        data.push(temp[1],temp[2],10,temp[3],temp[4],10,temp[5],temp[6]);
    })();

    /*生成点阵数字*/
    function renderDigit(index,num){
        for(var i = 0; i < digit[num].length; i++){
            for(var j = 0; j < digit[num][i].length; j++){
                if(digit[num][i][j] == 1){
                    cxt.beginPath();
                    cxt.arc(14*(R+2)*index + j*2*(R+1)+(R+1),i*2*(R+1)+(R+1),R,0,2*Math.PI);
                    cxt.closePath();
                    cxt.fill();
                }
            }
        }
    }

    /*更新时钟*/
    function updateDigitTime(){
        var changeNumArray = [];
        var temp = /(\d)(\d):(\d)(\d):(\d)(\d)/.exec(new Date());
        var NewData = [];
        NewData.push(temp[1],temp[2],10,temp[3],temp[4],10,temp[5],temp[6]);
        for(var i = data.length-1; i >=0 ; i--){
            //时间发生变化
            if(NewData[i] !== data[i]){
                //将变化的数字值和在data数组中的索引存储在changeNumArray数组中
                changeNumArray.push(i+'_'+(Number(data[i])+1)%10);
            }
        }
        //增加小球
        for(var i = 0; i< changeNumArray.length; i++){
            addBalls.apply(this,changeNumArray[i].split('_'));
        }
        data = NewData.concat();
    }

    /*更新小球状态*/
    function updateBalls(){
        for(var i = 0; i < balls.length; i++){
            balls[i].stepY += balls[i].disY;
            balls[i].x += balls[i].stepX;
            balls[i].y += balls[i].stepY;
            if(balls[i].x > W + R || balls[i].y > H + R){
                balls.splice(i,1);
                i--;
            }
        }
    }

    /*增加要运动的小球*/
    function addBalls(index,num){
        var numArray = [1,2,3];
        var colorArray =  ["#3BE","#09C","#A6C","#93C","#9C0","#690","#FB3","#F80","#F44","#C00"];
        for(var i = 0; i < digit[num].length; i++){
            for(var j = 0; j < digit[num][i].length; j++){
                if(digit[num][i][j] == 1){
                    var ball = {
                        x:14*(R+2)*index + j*2*(R+1)+(R+1),
                        y:i*2*(R+1)+(R+1),
                        stepX:Math.floor(Math.random() * 4 -2),
                        stepY:-2*numArray[Math.floor(Math.random()*numArray.length)],
                        color:colorArray[Math.floor(Math.random()*colorArray.length)],
                        disY:1
                    };
                    balls.push(ball);
                }
            }
        }
    }

    /*渲染*/
    function render(){
        //重置画布宽度，达到清空画布的效果
        canvas.height = 100;
        //渲染时钟
        for(var i = 0; i < data.length; i++){
            renderDigit(i,data[i]);
        }
        //渲染小球
        for(var i = 0; i < balls.length; i++){
            cxt.beginPath();
            cxt.arc(balls[i].x,balls[i].y,R,0,2*Math.PI);
            cxt.fillStyle = balls[i].color;
            cxt.closePath();
            cxt.fill();
        }
    }

    clearInterval(oTimer);
    var oTimer = setInterval(function(){
        //更新时钟
        updateDigitTime();
        //更新小球状态
        updateBalls();
        //渲染
        render();
    },50);
}

})();
</script>



        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#第十三章-字符串"><span class="nav-number">1.</span> <span class="nav-text">第十三章 字符串</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#13-1-不可变的string"><span class="nav-number">1.1.</span> <span class="nav-text">13.1 不可变的string</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-2-重载“-”与StringBuilder"><span class="nav-number">1.2.</span> <span class="nav-text">13.2 重载“+”与StringBuilder</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-3-无意识的递归"><span class="nav-number">1.3.</span> <span class="nav-text">13.3 无意识的递归</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-4-String上的操作"><span class="nav-number">1.4.</span> <span class="nav-text">13.4 String上的操作</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-5-格式化输出"><span class="nav-number">1.5.</span> <span class="nav-text">13.5 格式化输出</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-6-正则表达式"><span class="nav-number">1.6.</span> <span class="nav-text">13.6 正则表达式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#13-7-扫描输入"><span class="nav-number">1.7.</span> <span class="nav-text">13.7 扫描输入</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#13-8-StringTokenizer"><span class="nav-number">2.</span> <span class="nav-text">13.8 StringTokenizer</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#13-9-总结"><span class="nav-number">2.1.</span> <span class="nav-text">13.9 总结</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

	
           
         
         <div style>
  <canvas id="canvas" style="width:60%;">当前浏览器不支持canvas，请更换浏览器后再试</canvas>
</div>
<script>
(function(){

   var digit=
    [
        [
            [0,0,1,1,1,0,0],
            [0,1,1,0,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,0,1,1,0],
            [0,0,1,1,1,0,0]
        ],//0
        [
            [0,0,0,1,1,0,0],
            [0,1,1,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [1,1,1,1,1,1,1]
        ],//1
        [
            [0,1,1,1,1,1,0],
            [1,1,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,0,0],
            [0,0,1,1,0,0,0],
            [0,1,1,0,0,0,0],
            [1,1,0,0,0,0,0],
            [1,1,0,0,0,1,1],
            [1,1,1,1,1,1,1]
        ],//2
        [
            [1,1,1,1,1,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,0,0,1,1,0],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0]
        ],//3
        [
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,1,0],
            [0,0,1,1,1,1,0],
            [0,1,1,0,1,1,0],
            [1,1,0,0,1,1,0],
            [1,1,1,1,1,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,0,1,1,0],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,1,1]
        ],//4
        [
            [1,1,1,1,1,1,1],
            [1,1,0,0,0,0,0],
            [1,1,0,0,0,0,0],
            [1,1,1,1,1,1,0],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0]
        ],//5
        [
            [0,0,0,0,1,1,0],
            [0,0,1,1,0,0,0],
            [0,1,1,0,0,0,0],
            [1,1,0,0,0,0,0],
            [1,1,0,1,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0]
        ],//6
        [
            [1,1,1,1,1,1,1],
            [1,1,0,0,0,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,0,0],
            [0,0,0,1,1,0,0],
            [0,0,1,1,0,0,0],
            [0,0,1,1,0,0,0],
            [0,0,1,1,0,0,0],
            [0,0,1,1,0,0,0]
        ],//7
        [
            [0,1,1,1,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,1,1,0]
        ],//8
        [
            [0,1,1,1,1,1,0],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [1,1,0,0,0,1,1],
            [0,1,1,1,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,0,1,1],
            [0,0,0,0,1,1,0],
            [0,0,0,1,1,0,0],
            [0,1,1,0,0,0,0]
        ],//9
        [
            [0,0,0,0,0,0,0],
            [0,0,1,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,0,0,0,0,0],
            [0,0,0,0,0,0,0],
            [0,0,1,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,1,1,1,0,0],
            [0,0,0,0,0,0,0]
        ]//:
    ];

var canvas = document.getElementById('canvas');

if(canvas.getContext){
    var cxt = canvas.getContext('2d');
    //声明canvas的宽高
    var H = 100,W = 700;
    canvas.height = H;
    canvas.width = W;
    cxt.fillStyle = '#f00';
    cxt.fillRect(10,10,50,50);

    //存储时间数据
    var data = [];
    //存储运动的小球
    var balls = [];
    //设置粒子半径
    var R = canvas.height/20-1;
    (function(){
        var temp = /(\d)(\d):(\d)(\d):(\d)(\d)/.exec(new Date());
        //存储时间数字，由十位小时、个位小时、冒号、十位分钟、个位分钟、冒号、十位秒钟、个位秒钟这7个数字组成
        data.push(temp[1],temp[2],10,temp[3],temp[4],10,temp[5],temp[6]);
    })();

    /*生成点阵数字*/
    function renderDigit(index,num){
        for(var i = 0; i < digit[num].length; i++){
            for(var j = 0; j < digit[num][i].length; j++){
                if(digit[num][i][j] == 1){
                    cxt.beginPath();
                    cxt.arc(14*(R+2)*index + j*2*(R+1)+(R+1),i*2*(R+1)+(R+1),R,0,2*Math.PI);
                    cxt.closePath();
                    cxt.fill();
                }
            }
        }
    }

    /*更新时钟*/
    function updateDigitTime(){
        var changeNumArray = [];
        var temp = /(\d)(\d):(\d)(\d):(\d)(\d)/.exec(new Date());
        var NewData = [];
        NewData.push(temp[1],temp[2],10,temp[3],temp[4],10,temp[5],temp[6]);
        for(var i = data.length-1; i >=0 ; i--){
            //时间发生变化
            if(NewData[i] !== data[i]){
                //将变化的数字值和在data数组中的索引存储在changeNumArray数组中
                changeNumArray.push(i+'_'+(Number(data[i])+1)%10);
            }
        }
        //增加小球
        for(var i = 0; i< changeNumArray.length; i++){
            addBalls.apply(this,changeNumArray[i].split('_'));
        }
        data = NewData.concat();
    }

    /*更新小球状态*/
    function updateBalls(){
        for(var i = 0; i < balls.length; i++){
            balls[i].stepY += balls[i].disY;
            balls[i].x += balls[i].stepX;
            balls[i].y += balls[i].stepY;
            if(balls[i].x > W + R || balls[i].y > H + R){
                balls.splice(i,1);
                i--;
            }
        }
    }

    /*增加要运动的小球*/
    function addBalls(index,num){
        var numArray = [1,2,3];
        var colorArray =  ["#3BE","#09C","#A6C","#93C","#9C0","#690","#FB3","#F80","#F44","#C00"];
        for(var i = 0; i < digit[num].length; i++){
            for(var j = 0; j < digit[num][i].length; j++){
                if(digit[num][i][j] == 1){
                    var ball = {
                        x:14*(R+2)*index + j*2*(R+1)+(R+1),
                        y:i*2*(R+1)+(R+1),
                        stepX:Math.floor(Math.random() * 4 -2),
                        stepY:-2*numArray[Math.floor(Math.random()*numArray.length)],
                        color:colorArray[Math.floor(Math.random()*colorArray.length)],
                        disY:1
                    };
                    balls.push(ball);
                }
            }
        }
    }

    /*渲染*/
    function render(){
        //重置画布宽度，达到清空画布的效果
        canvas.height = 100;
        //渲染时钟
        for(var i = 0; i < data.length; i++){
            renderDigit(i,data[i]);
        }
        //渲染小球
        for(var i = 0; i < balls.length; i++){
            cxt.beginPath();
            cxt.arc(balls[i].x,balls[i].y,R,0,2*Math.PI);
            cxt.fillStyle = balls[i].color;
            cxt.closePath();
            cxt.fill();
        }
    }

    clearInterval(oTimer);
    var oTimer = setInterval(function(){
        //更新时钟
        updateDigitTime();
        //更新小球状态
        updateBalls();
        //渲染
        render();
    },50);
}

})();
</script>



    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">190coder</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>





<div>
    <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
    <span class="post-meta-divider">|</span>
    <span id="busuanzi_container_site_uv">本站访客数<span id="busuanzi_value_site_uv"></span>人</span>
</div>


        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/gh/theme-next/theme-next-canvas-nest@1/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
